import app from "@/app"
import { emptyExtInfo, ExtInfo } from "./ExtInfo"

export class BasicInfoViewModel {
    projectName: string; // 项目名称
    speciality: string; // 所属学科
    departId: string// 负责学院
    belongDepartId: string; // 所属学院
    projectSource: string; // 项目来源
    problemSource: string; // 课题来源
    completeMethod: string; // 是否在实验、实践中完成
    labType: string; // 实验室类型
    labName: string; // 实验室名称
    praticeLocation: string; // 拟进行实践的地点
    applyStartDate: string; // 项目开始时间
    applyEndDate: string; // 项目结束时间
    managerSciResearch: string; // 主持人曾经参与科研的情况
    guideTeacherSciResearch: string; // 指导教师承担科研课题情况
    
    constructor(
        projectName: string = '',
        speciality: string = '',
        departId: string = app.GUID_EMPTY,
        belongDepartId: string = app.GUID_EMPTY,
        projectSource: string = '',
        problemSource: string = '',
        completeMethod: string = '否',
        labType: string = '',
        labName: string = '',
        praticeLocation: string = '',
        applyStartDate: string = app.DATE_EMPTY,
        applyEndDate: string = app.DATE_EMPTY,
        managerSciResearch: string = '',
        guideTeacherSciResearch: string = ''
    ) {
        this.projectName = projectName;
        this.speciality = speciality;
        this.departId = (departId === app.GUID_EMPTY ?  app.currentUser.Roles.find(r => r.ForDepart !== app.GUID_EMPTY)?.ForDepart : departId) || app.GUID_EMPTY;
        this.belongDepartId = (belongDepartId === app.GUID_EMPTY ?  app.currentUser.Roles.find(r => r.ForDepart !== app.GUID_EMPTY)?.ForDepart : belongDepartId) || app.GUID_EMPTY;
        this.projectSource = projectSource;
        this.problemSource = problemSource;
        this.completeMethod = completeMethod;
        this.labType = labType;
        this.labName = labName;
        this.praticeLocation = praticeLocation;
        this.applyStartDate = applyStartDate;
        this.applyEndDate = applyEndDate;
        this.managerSciResearch = managerSciResearch;
        this.guideTeacherSciResearch = guideTeacherSciResearch;
    }
}

// 创新训练
export class InnoVInfoViewModel extends BasicInfoViewModel {
    guideTeacherSupport: string;

    constructor(
        projectName: string = '',
        speciality: string = '',
        departId: string = app.GUID_EMPTY,
        belongDepartId: string = app.GUID_EMPTY,
        projectSource: string = '',
        problemSource: string = '',
        completeMethod: string = '否',
        labType: string = '',
        labName: string = '',
        praticeLocation: string = '',
        applyStartDate: string = app.DATE_EMPTY,
        applyEndDate: string = app.DATE_EMPTY,
        managerSciResearch: string = '',
        guideTeacherSciResearch: string = '',
        guideTeacherSupport: string = ''
    ) {
        super(projectName, speciality, departId, belongDepartId, projectSource, problemSource, completeMethod, labType, labName, praticeLocation, applyStartDate, applyEndDate, managerSciResearch, guideTeacherSciResearch);
        this.guideTeacherSupport = guideTeacherSupport;
    }

    static fromModel (basicInfo: ProjBasicInfo, extInfo: ExtInfo) : InnoVInfoViewModel {
        return new InnoVInfoViewModel(
            basicInfo.ProjectName,
            basicInfo.Speciality,
            basicInfo.DepartId,
            basicInfo.BelongDepartId,
            basicInfo.ProjectSource,
            basicInfo.ProblemSource,
            basicInfo.CompleteMethod,
            basicInfo.LabType,
            basicInfo.LabName,
            basicInfo.PraticeLocation,
            basicInfo.ApplyStartDate,
            basicInfo.ApplyEndDate,
            extInfo.ManagerSciResearch,
            extInfo.GuideTeacherSciResearch,
            extInfo.GuideTeacherSupport
        );
    };
}

// 校长基金 
export class PrinFInfoViewModel extends BasicInfoViewModel {
    guideTeacherSupport: string;

    constructor(
        projectName: string = '',
        speciality: string = '',
        departId: string = app.GUID_EMPTY,
        belongDepartId: string = app.GUID_EMPTY,
        projectSource: string = '',
        problemSource: string = '',
        completeMethod: string = '否',
        labType: string = '',
        labName: string = '',
        praticeLocation: string = '',
        applyStartDate: string = app.DATE_EMPTY,
        applyEndDate: string = app.DATE_EMPTY,
        managerSciResearch: string = '',
        guideTeacherSciResearch: string = '',
        guideTeacherSupport: string = ''
    ) {
        super(projectName, speciality, departId, belongDepartId, projectSource, problemSource, completeMethod, labType, labName, praticeLocation, applyStartDate, applyEndDate, managerSciResearch, guideTeacherSciResearch);
        this.guideTeacherSupport = guideTeacherSupport;
    }

    static fromModel (basicInfo: ProjBasicInfo, extInfo: ExtInfo) : PrinFInfoViewModel {
        return new PrinFInfoViewModel(
            basicInfo.ProjectName,
            basicInfo.Speciality,
            basicInfo.DepartId,
            basicInfo.BelongDepartId,
            basicInfo.ProjectSource,
            basicInfo.ProblemSource,
            basicInfo.CompleteMethod,
            basicInfo.LabType,
            basicInfo.LabName,
            basicInfo.PraticeLocation,
            basicInfo.ApplyStartDate,
            basicInfo.ApplyEndDate,
            extInfo.ManagerSciResearch,
            extInfo.GuideTeacherSciResearch,
            extInfo.GuideTeacherSupport
        );
    }
}

// 创业实践
export class EntrPInfoViewModel extends BasicInfoViewModel {
    corpTeacher: string;
    corpTeacherMobile: string;
    corpTeacherSciResearch: string;
    
    constructor(
        projectName: string = '',
        speciality: string = '',
        departId: string = app.GUID_EMPTY,
        belongDepartId: string = app.GUID_EMPTY,
        projectSource: string = '',
        problemSource: string = '',
        completeMethod: string = '否',
        labType: string = '',
        labName: string = '',
        praticeLocation: string = '',
        applyStartDate: string = app.DATE_EMPTY,
        applyEndDate: string = app.DATE_EMPTY,
        managerSciResearch: string = '',
        guideTeacherSciResearch: string = '',
        corpTeacher: string = '',
        corpTeacherMobile: string = '',
        corpTeacherSciResearch: string = ''
    ) {
        super(projectName, speciality, departId, belongDepartId, projectSource, problemSource, completeMethod, labType, labName, praticeLocation, applyStartDate, applyEndDate, managerSciResearch, guideTeacherSciResearch);
        this.corpTeacher = corpTeacher;
        this.corpTeacherMobile = corpTeacherMobile;
        this.corpTeacherSciResearch = corpTeacherSciResearch;
    }

    static fromModel (basicInfo: ProjBasicInfo, extInfo: ExtInfo) : EntrPInfoViewModel {
        return new EntrPInfoViewModel(
            basicInfo.ProjectName,
            basicInfo.Speciality,
            basicInfo.DepartId,
            basicInfo.BelongDepartId,
            basicInfo.ProjectSource,
            basicInfo.ProblemSource,
            basicInfo.CompleteMethod,
            basicInfo.LabType,
            basicInfo.LabName,
            basicInfo.PraticeLocation,
            basicInfo.ApplyStartDate,
            basicInfo.ApplyEndDate,
            extInfo.ManagerSciResearch,
            extInfo.GuideTeacherSciResearch,
            extInfo.CorpTeacher,
            extInfo.CorpTeacherMobile,
            extInfo.CorpTeacherSciResearch
        );
    };
}

// 创业训练
export class EntrTInfoViewModel extends BasicInfoViewModel {
    corpTeacher: string;
    corpTeacherMobile: string;
    corpTeacherSciResearch: string;
    
    constructor(
        projectName: string = '',
        speciality: string = '',
        departId: string = app.GUID_EMPTY,
        belongDepartId: string = app.GUID_EMPTY,
        projectSource: string = '',
        problemSource: string = '',
        completeMethod: string = '否',
        labType: string = '',
        labName: string = '',
        praticeLocation: string = '',
        applyStartDate: string = app.DATE_EMPTY,
        applyEndDate: string = app.DATE_EMPTY,
        managerSciResearch: string = '',
        guideTeacherSciResearch: string = '',
        corpTeacher: string = '',
        corpTeacherMobile: string = '',
        corpTeacherSciResearch: string = ''
    ) {
        super(projectName, speciality, departId, belongDepartId, projectSource, problemSource, completeMethod, labType, labName, praticeLocation, applyStartDate, applyEndDate, managerSciResearch, guideTeacherSciResearch);
        this.corpTeacher = corpTeacher;
        this.corpTeacherMobile = corpTeacherMobile;
        this.corpTeacherSciResearch = corpTeacherSciResearch;
    }

    static fromModel (basicInfo: ProjBasicInfo, extInfo: ExtInfo) : EntrTInfoViewModel {
        return new EntrTInfoViewModel(
            basicInfo.ProjectName,
            basicInfo.Speciality,
            basicInfo.DepartId,
            basicInfo.BelongDepartId,
            basicInfo.ProjectSource,
            basicInfo.ProblemSource,
            basicInfo.CompleteMethod,
            basicInfo.LabType,
            basicInfo.LabName,
            basicInfo.PraticeLocation,
            basicInfo.ApplyStartDate,
            basicInfo.ApplyEndDate,
            extInfo.ManagerSciResearch,
            extInfo.GuideTeacherSciResearch,
            extInfo.CorpTeacher,
            extInfo.CorpTeacherMobile,
            extInfo.CorpTeacherSciResearch
        );
    };
}

export interface ProjBasicInfo  {
    "ProjectType": string,
    "ProjectName": string,
    "Speciality": string,
    "ProjectCode": string,
    "ProjectLevel": string,
    "ProjectNumber": string,
    "ProjectOrder": number,
    "CompleteMethod": string,
    "LabType": string,
    "LabName": string,
    "PraticeLocation": string,
    "ProblemSource": string,
    "ProjectSource": string,
    "ApplyYear": string,
    "Batch": string,
    "ApplyStartDate": string,
    "ApplyEndDate": string,
    "ProjOwnerId": string,
    "ProjOwnerCode": string,
    "ProjOwner": string,
    "ProjOwnerGender": string,
    "ProjOwnerEthnic": string,
    "ProjOwnerBirthday": string,
    "ProjOwnerMobile": string,
    "ProjOwnerMajor": string,
    "ProjOwnerDepartment": string,
    "ProjOwnerReformType": ""|"无"|"强基计划"|"拔尖计划",
    "GuideTeacherId": string,
    "GuideTeacherCode": string,
    "GuideTeacher": string,
    "GuideTeacherMobile": string,
    "GuideTeacherTitle": string,
    "GuideTeacherEducation": string,
    "GuideTeacherEmail": string,
    "OtherTeacher": string,
    "DepartId": string,
    "DepartName": string,
    "BelongDepartId": string,
    "BelongDepartName": string,
    "WorkflowVersion": string,
    "DeleteMark": 0|1,
    "CreateOn": string,
    "CreateUserId": string,
    "CreateBy": string,
    "Status": number,
    "FullProcessStatus": number,
    "SrcId": string,
    "SrcTimestamp": number,
    "Remark": string
    "ApplyAmount": number,
    "ApprovalAmount": number,
    "Balance": number,
    "ID": string,
    canEdit: boolean,
    canSee: boolean,
    readonly: boolean,
    isNew: boolean,
    /**
     * 此参数是枚举值，0 代表无权访问，10 代表权限为学生，20 代表权限是指导老师，30 代表权限是院管，40 代表权限是教务处
     */
    accessLevel: number,
};

export interface Data {
    [prop: string]: any
};

export const emptyBasicInfo : ProjBasicInfo = {
    canEdit: false,
    canSee: false,
    readonly: true,
    isNew: true,
    accessLevel: 0,
    "ProjectType": "",
    "ProjectName": "",
    "Speciality": "",
    "ProjectCode": "",
    "ProjectLevel": "",
    "ProjectNumber": "",
    "ProjectOrder": 0,
    "CompleteMethod": "",
    "LabType": "",
    "LabName": "",
    "PraticeLocation": "",
    "ProblemSource": "",
    "ProjectSource": "",
    "ApplyYear": "",
    "Batch": "",
    "ApplyStartDate": "",
    "ApplyEndDate": "",
    "ProjOwnerId": app.GUID_EMPTY,
    "ProjOwnerCode": "",
    "ProjOwner": "",
    "ProjOwnerGender": "",
    "ProjOwnerEthnic": "",
    "ProjOwnerBirthday": "",
    "ProjOwnerMobile": "",
    "ProjOwnerMajor": "",
    "ProjOwnerDepartment": "",
    "ProjOwnerReformType": "",
    "GuideTeacherId": app.GUID_EMPTY,
    "GuideTeacherCode": "",
    "GuideTeacher": "",
    "GuideTeacherMobile": "",
    "GuideTeacherTitle": "",
    "GuideTeacherEducation": "",
    "GuideTeacherEmail": "",
    "OtherTeacher": "",
    "DepartId": app.GUID_EMPTY,
    "DepartName": "",
    "BelongDepartId": app.GUID_EMPTY,
    "BelongDepartName": "",
    "WorkflowVersion": "",
    "DeleteMark": 0,
    "CreateOn": "",
    "CreateUserId": app.GUID_EMPTY,
    "CreateBy": "",
    "Status": 0,
    "FullProcessStatus": 0,
    "SrcId": app.GUID_EMPTY,
    "SrcTimestamp": 0,
    "Remark": "",
    "ApplyAmount": 0.00,
    "ApprovalAmount": 0.00,
    "Balance": 0.00,
    "ID": app.GUID_EMPTY
};